package com.ae.shield.common.capability.energy;

import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class ProEnergyStorage implements ICapabilityProvider {

    private final LazyOptional<IEnergyStorage> lazyOptional;

    public ProEnergyStorage(ItemStack stack, int capacity, int maxExtract, int maxReceive){
        lazyOptional = LazyOptional.of(() -> new ItemEnergyStorage(stack, capacity, maxExtract, maxReceive));
    }

    @Nonnull
    @Override
    public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
        return CapabilityEnergy.ENERGY.orEmpty(cap, lazyOptional);
    }
}
